package 数据结构和算法入门计划8月开始;

import java.util.Arrays;
// https://leetcode-cn.com/problems/get-maximum-in-generated-array/
public class 获取生成数组中的最大值16460823 {
    class Solution {
        public int getMaximumGenerated(int n) {
            if (n == 0) {
                return 0;
            }
            int[] nums = new int[n + 1];
            nums[1] = 1;
            for (int i = 2; i <= n; ++i) {
                nums[i] = nums[i / 2] + i % 2 * nums[i / 2 + 1];
            }
            return Arrays.stream(nums).max().getAsInt();
        }
    }

}
